package com.rpay.web.controller.question;

import com.rpay.common.dto.question.QuestionDTO;
import com.rpay.common.dto.question.QuestionQueryDTO;
import com.rpay.common.vo.PcsResult;
import com.rpay.web.interceptor.authentic.AccessControl;
import com.rpay.web.interceptor.authentic.AccessControlType;
import com.rpay.web.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author XXX
 * @mail XXX@hotmail.com
 * @date 2018/5/7
 * @Description:
 */
@RestController
@RequestMapping(value = "api/question")
@AccessControl(type = AccessControlType.SECRET)
public class QuestionController {
    @Autowired
    private QuestionService questionService;

    //获取问题列表
    @GetMapping(value = "")
    public PcsResult list(
            @RequestParam(name = "type", defaultValue = "") String questionType,
            @RequestParam(name = "page", defaultValue = "1") Integer page,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize
    ) {
        QuestionQueryDTO data = questionService.data(questionType,page, pageSize);
        return PcsResult.build(data);
    }

    //获取问题详情
    @GetMapping(value = "/detail/{id}")
    public PcsResult detail(@PathVariable("id") Integer id) {
        QuestionDTO questionDetail = questionService.detail(id);
        return PcsResult.build(questionDetail);
    }
}
